package core.world;

import java.awt.Point;
import java.util.Vector;

import core.Constants;
import core.GameOptions;

public class Map {
	
	public Vector<Wall> walls = new Vector<Wall>();
	public Vector<WallGroup> wallGroups = new Vector<WallGroup>();
	public Vector<Point> spawnPoints = new Vector<Point>();
	public Vector<NamedPoint> namedPoints = new Vector<NamedPoint>();
	public Vector<PointGroup> pointGroups = new Vector<PointGroup>();
	

	
	public Map(String filename){
		int gs = Constants.gridSize;

		MapFileReader.loadFile(filename, this);
	}
	
	
	public Point getSpawnPoint(int i){
		return spawnPoints.get(i);
	}
	public void addCornerWalls(int mapSize){
		walls.add(new Wall(new Point(0, 0),
				new Point(mapSize, 0)));
		walls.add(new Wall(new Point(mapSize, 0),
			new Point(mapSize, mapSize)));
		walls.add(new Wall(new Point(mapSize, mapSize),
			new Point(0, mapSize)));
		walls.add(new Wall(new Point(0, mapSize),
			new Point(0, 0)));
	}
	public void addWall(Wall w){
		walls.add(w);
	}
	public void addWallGroup(WallGroup wg){
		wallGroups.add(wg);
		walls.addAll(wg.getWalls());
	}
	public void addSpawn(Point p){
		spawnPoints.add(p);
	}
	public void addNamedPoint(String n, Point p){
		NamedPoint np = new NamedPoint(p);
		np.name = n;
		namedPoints.add(np);
	}
	public void addPointGroup(String n, Vector<Point> p){
		pointGroups.add(new PointGroup(n, p));
	}
	public Vector<Point> getPoints(String name){
		for(PointGroup pg : pointGroups){
			if(pg.name.equals(name)){
				return pg.points;
			}
		}
		return new Vector<Point>();
	}
	
	
	private class NamedPoint extends Point{
		
		public NamedPoint(Point p) {
			super(p);
		}

		private String name;
	}
	private class PointGroup{
		public PointGroup(String name, Vector<Point> points){
			this.name=name;
			this.points=points;
		}
		private String name;
		private Vector<Point> points;
	}
}
